package com.spzx.report.service.impl;

import com.spzx.report.mapper.VectorCountKeyMapper;
import com.spzx.report.mapper.VectorGroupKeyMapper;
import com.spzx.report.mapper.VectorSelectKeyMapper;
import com.spzx.report.service.SpzxEmbeddingService;
import com.spzx.report.vectorTools.PineconeKeyConst;
import com.spzx.report.vectorTools.PineconeUploadUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SpzxEmbeddingServiceImpl implements SpzxEmbeddingService {

    @Autowired
    VectorCountKeyMapper vectorCountKeyMapper;

    @Autowired
    VectorGroupKeyMapper vectorGroupKeyMapper;

    @Autowired
    VectorSelectKeyMapper vectorSelectKeyMapper;

    @Override
    public void embeddingGroupKeyToPinecone(){
        // 1 查询需要向量化的输入
        List<Map<String, Object>> groupKeyMaps = vectorGroupKeyMapper.selectMaps(null);
        // 2 存入pinecone
        PineconeUploadUtil.uploadListToPinecone(groupKeyMaps, PineconeKeyConst.PGK_INDEX_UPSERT_URL,PineconeKeyConst.PINECONE_KEY);
    }

    @Override
    public void embeddingCountKeyToPinecone(){
        // 1 查询需要向量化的输入
        List<Map<String, Object>> countKeyMaps = vectorCountKeyMapper.selectMaps(null);
        // 2 存入pinecone
        PineconeUploadUtil.uploadListToPinecone(countKeyMaps,PineconeKeyConst.PCK_INDEX_UPSERT_URL,PineconeKeyConst.PINECONE_KEY);
    }

    @Override
    public void embeddingSelectKeyToPinecone() {
        // 1 查询需要向量化的输入
        List<Map<String, Object>> selectKeyMaps = vectorSelectKeyMapper.selectMaps(null);
        // 2 存入pinecone
        PineconeUploadUtil.uploadListToPinecone(selectKeyMaps,PineconeKeyConst.PSK_INDEX_UPSERT_URL,PineconeKeyConst.PINECONE_KEY);
    }


}